package com.集合.Map集合;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/*Map集合的遍历 1*/
public class MapDemo4 {
    public static void main(String[] args) {

        Map<String, String> m = new HashMap<String, String>();
        m.put("张三", "李四");
        m.put("汤姆", "杰瑞");
        m.put("海绵宝宝", "派大星");

        //获取所有键的集合---keySet()方法实现
        Set<String> s = m.keySet();
        //遍历键的集合---增强for实现
        for (String ss : s) {
            //根据键去找值---get(Object key)方法实现
            String value = m.get(ss);
            System.out.println("键值对:" + ss + "," + value);
        }
    }
}
